import 'package:permission_handler/permission_handler.dart';

class PermissionUtil {

  static Future<bool> getPermissionStatus(Permission permission) async {
    PermissionStatus status = await permission.status;
    if (status.isGranted) {
      return true;
    } else if (status.isDenied) {
      return requestPermission(permission);
    } else if (status.isPermanentlyDenied) {
      await openAppSettings();
    } else if (status.isRestricted) {
      return requestPermission(permission);
    }
    return false;
  }

  static Future<bool> requestPermission(Permission permission) async {
    PermissionStatus status = await permission.request();
    if (status.isGranted) {
      return true;
    }
    return false;
  }
}